//package com.zpz.framework.zpzoauth.config.exception;
//
//
//import com.zpz.framework.zpzoauth.common.result.ResultMsg;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.boot.web.servlet.error.ErrorAttributes;
//import org.springframework.boot.web.servlet.error.ErrorController;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.context.request.ServletWebRequest;
//import org.springframework.web.context.request.WebRequest;
//
//import javax.servlet.http.HttpServletRequest;
//import java.util.Map;
//
///*
// * @author zhangpanzhi
// * @date 2018-04-12
// * @desc * 全局异常处理，当异常被@ControllerAdvice时不会走到这个处理类，没被处理时会走到这里
// *       例如 @valid入参校验失败的是不会走ControllerAdvice的，但会走这个处理器
// * */
///*@RestController
//@ApiIgnore*/
//public class GolablExceptionEndpoint implements ErrorController {
//    private static Logger logger = LoggerFactory.getLogger(GolablExceptionEndpoint.class);
//    private static final String PATH = "/error";
//
//    @Autowired
//    private ErrorAttributes errorAttributes;
//
//    @Override
//    public String getErrorPath() {
//        return PATH;
//    }
//
//
//    @RequestMapping(value = PATH)
//    public ResultMsg<Object> error(HttpServletRequest request) {
//        return handlerError(request, false);
//    }
//
//
//    private ResultMsg<Object> handlerError(HttpServletRequest request, boolean includeStackTrace) {
//
////        RequestAttributes requestAttributes = new ServletRequestAttributes(request);
//        WebRequest requestAttributes =new ServletWebRequest(request);
//        Throwable e = errorAttributes.getError(requestAttributes);
//        try {
//            StackTraceElement[] stackTrace = e.getStackTrace();
//            String s = stackTrace.toString();
//            StringBuffer bs=new StringBuffer();
//            for (StackTraceElement ste:stackTrace) {
//                bs.append(ste.toString()+"<br/>");
//            }
//        }catch (Exception le){
//            logger.info("***************日志插入异常"+le.getMessage());
//        }
//        Map<String, Object> data = errorAttributes.getErrorAttributes(requestAttributes, includeStackTrace);
//        StringBuilder detailMessage = new StringBuilder("");
//        if (null != data.get("error")) {
//            detailMessage.append(String.valueOf(data.get("error"))).append(":");
//        }
//        if (null == e || null == e.getMessage()) {
//            if (null != data.get("message")) {
//                detailMessage.append(String.valueOf(data.get("message")));
//            }
//        } else {
//            detailMessage.append(e.getMessage());
//        }
//        //logger.error(e.getMessage(),e);
//        return ResultMsg.error("ss");
//    }
//
//
//}
